package test.junits;

import com.jayway.android.robotium.solo.Solo;
import android.test.ActivityInstrumentationTestCase2;
import android.widget.TextView;
import matt.design.LoginActivity;
import matt.design.R;

public class CameronTests2 extends ActivityInstrumentationTestCase2<LoginActivity>{
	Solo solo;
	
	public CameronTests2(){
		super("matt.design",LoginActivity.class);
	}
	
	@Override
	protected void setUp() throws Exception{
		solo = new Solo(getInstrumentation(), getActivity());
	}

	public void testFilterAfterDate(){
		String username = "testFilterAfterDate";
		String password = "filter";
		//Start by registering/logging in
		
		//now login
		solo.enterText(0, username);
		solo.enterText(1, password);
		solo.clickOnButton(0);
		solo.waitForActivity("HomepageActivity");
		
		//Now I need to create some tasks and filter!
		solo.clickOnImageButton(0);
		solo.enterText(0, "After");
		solo.clickOnButton(1);
		solo.setDatePicker(0, 2012, 5, 5); //5-5-2012
		solo.clickOnButton("Set");
		solo.clickOnButton("Add Task");
		
		solo.clickOnImageButton(0);
		solo.enterText(0, "Before");
		solo.clickOnButton(1); //default is 4-12-2012
		solo.clickOnButton("Set");
		solo.clickOnButton("Add Task");
		
		//do the filter
		//solo.sendKey(Solo.MENU);
		solo.clickOnMenuItem("Filter"); //should be filter
		solo.clickOnText("After Date");
		solo.setDatePicker(0, 2012, 5, 1);
		solo.clickOnButton("Set");
		
	}
	
	
	@Override
	protected void tearDown(){
		try {
			solo.finalize();
			super.tearDown();
		} catch (Throwable e) {
			e.printStackTrace();
		}
		
	}
}
